<?php
namespace app\index\controller;
use robot\Robot;
use think\Controller;

class Api extends Common
{
	public function test()
	{
		// $text = input('q');

		// $res = Robot::send($text);

		// $data = json_decode($res,true);

		// var_dump($data['results']);
		$url = "http://api.dataoke.com/index.php?r=Port/index";

		$query  = "&type=top100&appkey=qy0zqlt039&v=2";

		$url .= $query;

		// 初始化
		$curl = curl_init();
		//要发的地址
		curl_setopt($curl, CURLOPT_URL, $url);
		//头部要不要
		curl_setopt($curl, CURLOPT_HEADER, 0);
		//返回不直接输出,用变量可以接收
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		// 发送请求
		$data = curl_exec($curl);

		var_dump(json_decode($data,true));


	}
	public function getcity()
	{
		$ip = "50.136.120.48";

		$url = "http://ip.taobao.com/service/getIpInfo.php?ip={$ip}";

		$data = file_get_contents($url);

		$data = json_decode($data,true);

		

	}

	public function getcity1()
	{
		$ip = "50.136.120.48";

		$url = "http://ip.taobao.com/service/getIpInfo.php?ip={$ip}";

		// 初始化
		$curl = curl_init();
		//要发的地址
		curl_setopt($curl, CURLOPT_URL, $url);
		//头部要不要
		curl_setopt($curl, CURLOPT_HEADER, 0);
		//返回不直接输出,用变量可以接收
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		// 发送请求
		$data = curl_exec($curl);

		var_dump(json_decode($data,true));

	}

	public function tianqi()
	{
		$host = "https://jisutqybmf.market.alicloudapi.com";
	    $path = "/weather/query";
	    $method = "GET";
	    $appcode = "ab7bfa4f7d544241998ea5d8a8ddb028";
	    $headers = array();
	    array_push($headers, "Authorization:APPCODE " . $appcode);
	    $querys = "city=深圳";
	    $bodys = "";
	    $url = $host . $path . "?" . $querys;

	    $curl = curl_init();
	    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
	    curl_setopt($curl, CURLOPT_URL, $url);
	    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
	    curl_setopt($curl, CURLOPT_FAILONERROR, false);
	    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	    curl_setopt($curl, CURLOPT_HEADER, false);
	    if (1 == strpos("$".$host, "https://"))
	    {
	        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	    }
	    $data = curl_exec($curl);

	    var_dump(json_decode($data,true));
	}

	public function wuliu()
	{
		$host = "https://wdexpress.market.alicloudapi.com";
	    $path = "/gxali";
	    $method = "GET";
	    $appcode = "ab7bfa4f7d544241998ea5d8a8ddb028";
	    $headers = array();
	    array_push($headers, "Authorization:APPCODE " . $appcode);
	    $querys = "n=3368023377027&t=STO";
	    $bodys = "";
	    $url = $host . $path . "?" . $querys;

	    $curl = curl_init();
	    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
	    curl_setopt($curl, CURLOPT_URL, $url);
	    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
	    curl_setopt($curl, CURLOPT_FAILONERROR, false);
	    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	    curl_setopt($curl, CURLOPT_HEADER, false);
	    if (1 == strpos("$".$host, "https://"))
	    {
	        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	    }

	    $data = curl_exec($curl);

	    var_dump(json_decode($data,true));
	}

}